package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.SoulQuestion;
import com.tanhua.dubbo.api.db.QuestionTextApi;
import com.tanhua.dubbo.mapper.QuestionTextMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class QuestionTextApiImpl implements QuestionTextApi {

    @Autowired
    private QuestionTextMapper questionTextMapper;


    @Override
    public List<SoulQuestion> queryQuestion(String questionnaireId) {
        QueryWrapper<SoulQuestion> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SoulQuestion::getQuestionnaireId,questionnaireId);
        List<SoulQuestion> questionList = questionTextMapper.selectList(wrapper);
        return questionList;
    }



    @Override
    public String queryQuestionnaireId(String questionId) {
        QueryWrapper<SoulQuestion> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(SoulQuestion::getId,Integer.parseInt(questionId));
        SoulQuestion soulQuestion = questionTextMapper.selectOne(wrapper);
        return soulQuestion.getQuestionnaireId();
    }
}
